package com.edu.exam.enums.assessment.generation;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 适用范围枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum Scope implements BaseEnum {
    GLOBAL("GLOBAL", "全局"),
    SEMESTER("SEMESTER", "学期"),
    ACADEMIC_YEAR("ACADEMIC_YEAR", "学年"),
    DEPARTMENT("DEPARTMENT", "院系"),
    MAJOR("MAJOR", "专业"),
    COURSE("COURSE", "课程"),
    CLASS("CLASS", "班级"),
    STUDENT("STUDENT", "学生"),
    TEACHER("TEACHER", "教师");

    private final String code;
    private final String description;

    Scope(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static Scope fromCode(String code) {
        for (Scope scope : values()) {
            if (scope.getCode().equals(code)) {
                return scope;
            }
        }
        throw new IllegalArgumentException("Unknown scope code: " + code);
    }

    @Override
    public String toString() {
        return code + " - " + description;
    }
}
